package com.app.teaware.bean;

import com.alibaba.fastjson.annotation.JSONField;

import java.util.ArrayList;
import java.util.List;

public class UnitListBean extends BaseListBean{
    private ArrayList<UnitListData> list = new ArrayList<UnitListData>();

    public ArrayList<UnitListData> getList() {
        return list;
    }

    public void setList(ArrayList<UnitListData> list) {
        this.list = list;
    }

    @JSONField(serialize = false)
    public void addListBean(UnitListBean listbean) {
        if (listbean == null)
            return;
        if (this.getCurrentPage() == INIT_PAGE) {
            setList(listbean.getList());
        } else {
            if (list == null)
                list = new ArrayList<UnitListData>();
            list.addAll(listbean.getList());
        }
        setListBeanData(listbean);
    }

    //获得单位
    public List<String> getAllUnitSna(){
        List<String> listUnit = null;
        for(int i=0; i<list.size(); i++)
        {
            if(list.get(i).getDna().equals("单位"))
            {
                if(null == listUnit)
                    listUnit = new ArrayList<>();
                listUnit.add(list.get(i).getSna());
            }
        }
        return listUnit;
    }

    public String[] getAllUnits(){
        List<String> unitList = getAllUnitSna();
        if(unitList == null || unitList.size()== 0){
            return null;
        }
        String[] arr = unitList.toArray(new String[unitList.size()]);
        return arr;
    }
}
